var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
let window = _____WB$wombat$assign$function_____("window");
let self = _____WB$wombat$assign$function_____("self");
let document = _____WB$wombat$assign$function_____("document");
let location = _____WB$wombat$assign$function_____("location");
let top = _____WB$wombat$assign$function_____("top");
let parent = _____WB$wombat$assign$function_____("parent");
let frames = _____WB$wombat$assign$function_____("frames");
let opens = _____WB$wombat$assign$function_____("opens");
jQuery(document).ready(function ($) {
// DIAG - Diagnostics = Ver 1.4.2
// if (chatbotSettings.chatbot_chatgpt_diagnostics === 'On') {
// console.log('Chatbot: NOTICE: Entering chatbot-chatgpt.js');
// }
let chatGptChatBot = $('#chatbot-chatgpt').hide();
messageInput = $('#chatbot-chatgpt-message');
let conversation = $('#chatbot-chatgpt-conversation');
submitButton = $('#chatbot-chatgpt-submit');
uploadfileButton = $('#chatbot-chatgpt-upload-file');
chatGptOpenButton = $('#chatgpt-open-btn');
chatbotChatgptBotName = localStorage.getItem('chatbot_chatgpt_bot_name') || 'Kognetiks Chatbot';
chatbotChatgptBotPrompt = localStorage.getItem('chatbot_chatgpt_bot_prompt') || 'Enter your question ...';
// Determine the shortcode styling where default is 'floating' or 'embedded' - Ver 1.7.1
chatbot_chatgpt_display_style = localStorage.getItem('chatbot_chatgpt_display_style') || 'floating';
chatbot_chatgpt_assistant_alias = localStorage.getItem('chatbot_chatgpt_assistant_alias') || 'original';
initialGreeting = localStorage.getItem('chatbot_chatgpt_initial_greeting') || 'Hello! How can I help you today?';
subsequentGreeting = localStorage.getItem('chatbot_chatgpt_subsequent_greeting') || 'Hello again! How can I help you?';
chatbotChatgptDisplaySytle = localStorage.getItem('chatbot_chatgpt_display_style') || 'floating';
chatbotChatgptAssistantAlias = localStorage.getItem('chatbot_chatgpt_assistant_alias') || 'original';
chatbot_chatgpt_start_status = localStorage.getItem('chatbot_chatgpt_start_status') || 'closed';
chatbot_chatgpt_start_status_new_visitor = localStorage.getItem('chatbot_chatgpt_start_status_new_visitor') || 'closed';
chatbot_chatgpt_disclaimer_setting = localStorage.getItem('chatbot_chatgpt_disclaimer_setting') || 'Yes';
chatbot_chatgpt_width_setting = localStorage.getItem('chatbot_chatgpt_width_setting') || 'Narrow';
// Add variables for the timeout setting - Ver 1.8.8
timeout_setting = localStorage.getItem('chatbot_chatgpt_timeout_setting') || 240;
// console.log('Chatbot: NOTICE: timeout_setting: ' + timeout_setting);
// Convert the timeout setting to a number
timeout_setting = parseInt(timeout_setting);
// Convert the timeout setting to milliseconds
timeout_setting = timeout_setting * 1000;
plugins_url = plugin_vars.plugins_url;
// Get an open icon for the chatbot - Ver 1.8.6
chatbotopenicon = plugins_url + '/assets/icons/' + 'chat_FILL0_wght400_GRAD0_opsz24.png';
chatbotopenicon = $('')
.attr('id', 'chatbot-open-icon')
.attr('class', 'chatbot-open-icon')
.attr('src', chatbotopenicon);
// Get a collapse icon for the chatbot - Ver 1.8.6
chatbotcollapseicon = plugins_url + '/assets/icons/' + 'close_FILL0_wght400_GRAD0_opsz24.png';
chatbotcollapseicon = $('
')
.attr('id', 'chatbot-collapse-icon')
.attr('class', 'chatbot-collapse-icon')
.attr('src', chatbotcollapseicon);
// Get am erase icon for the chatbot - Ver 1.8.6
chatboteraseicon = plugins_url + '/assets/icons/' + 'delete_FILL0_wght400_GRAD0_opsz24.png';
chatboteraseicon = $('
')
.attr('id', 'chatbot-erase-icon')
.attr('class', 'chatbot-erase-icon')
.attr('src', chatboteraseicon);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_start_status: ' + chatbot_chatgpt_start_status);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_start_status_new_visitor: ' + chatbot_chatgpt_start_status_new_visitor);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_display_style: ' + chatbot_chatgpt_display_style);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_width_setting: ' + chatbot_chatgpt_width_setting);
// Determine the shortcode styling where default is 'floating' or 'embedded' - Ver 1.7.1
// var site-header = document.querySelector("#site-header");
// var site-footer = document.querySelector("#site-footer");
// if(header && footer) {
// var headerBottom = site-header.getBoundingClientRect().bottom;
// var footerTop = site-footer.getBoundingClientRect().top;
// var visible-distance = footerTop - headerBottom;
// console.log('Chatbot: NOTICE: Distance: + distance + 'px');
// }
if (chatbot_chatgpt_display_style === 'embedded') {
// Apply configurations for embedded style
$('#chatbot-chatgpt').addClass('embedded-style').removeClass('floating-style');
// Other configurations specific to embedded style
chatbot_chatgpt_start_status = 'open'; // Force the chatbot to open if embedded
chatbot_chatgpt_start_status_new_visitor = 'open'; // Force the chatbot to open if embedded
localStorage.setItem('chatbot_chatgpt_start_status', chatbot_chatgpt_start_status);
localStorage.setItem('chatbot_chatgpt_start_status_new_visitor', chatbot_chatgpt_start_status_new_visitor);
chatGptChatBot.addClass('embedded-style').removeClass('floating-style');
} else {
// Apply configurations for floating style
$('#chatbot-chatgpt').addClass('floating-style').removeClass('embedded-style');
// Other configurations specific to floating style
if (chatbot_chatgpt_width_setting === 'Wide') {
chatGptChatBot.addClass('wide');
} else {
// chatGptChatBot.removeClass('wide').css('display', 'none');
chatGptChatBot.removeClass('wide');
}
}
// Overrides for mobile devices - Ver 1.8.1
if (isMobile()) {
// console.log('Chatbot: NOTICE: chatbot_chatgpt_start_status: ' + chatbot_chatgpt_start_status);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_start_status_new_visitor: ' + chatbot_chatgpt_start_status_new_visitor);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_display_style: ' + chatbot_chatgpt_display_style);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_width_setting: ' + chatbot_chatgpt_width_setting);
if ( chatbot_chatgpt_display_style === 'embedded') {
// Apply configurations for embedded style
chatbot_chatgpt_start_status = 'open'; // Force the chatbot to open if embedded
chatbot_chatgpt_start_status_new_visitor = 'open'; // Force the chatbot to open if embedded
}
// chatbot_chatgpt_start_status = 'closed';
// chatbot_chatgpt_start_status_new_visitor = 'closed';
localStorage.setItem('chatbot_chatgpt_start_status', chatbot_chatgpt_start_status);
localStorage.setItem('chatbot_chatgpt_start_status_new_visitor', chatbot_chatgpt_start_status_new_visitor);
// Determine the viewport width and height
let viewportWidth = window.innerWidth;
let viewportHeight = window.innerHeight;
// console.log('Viewport Width:', viewportWidth, 'Viewport Height:', viewportHeight);
// Determine the orientation
const orientation = screen.orientation || screen.mozOrientation || screen.msOrientation;
if (orientation.type === 'landscape-primary') {
// console.log('Orientation: Landscape');
} else if (orientation.type === 'portrait-primary') {
// console.log('Orientation: Portrait');
} else {
// console.log('Orientation:', orientation.type);
}
updateChatbotStyles();
// Listen for orientation changes
window.addEventListener('orientationchange', updateChatbotStyles);
// Listen for resize events
window.addEventListener('resize', updateChatbotStyles);
// TODO - IF MOBILE REMOVE ICON AND SHOW DASHICON AND DETERMINE WIDTH AND ORIENTATION (PORTRAIT OR LANDSCAPE)
}
// console.log('Chatbot: NOTICE: chatbot_chatgpt_start_status: ' + chatbot_chatgpt_start_status);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_start_status_new_visitor: ' + chatbot_chatgpt_start_status_new_visitor);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_display_style: ' + chatbot_chatgpt_display_style);
// console.log('Chatbot: NOTICE: chatbot_chatgpt_width_setting: ' + chatbot_chatgpt_width_setting);
if ( chatbot_chatgpt_display_style === 'embedded') {
// Apply configurations for embedded style
chatbot_chatgpt_start_status = 'open'; // Force the chatbot to open if embedded
chatbot_chatgpt_start_status_new_visitor = 'open'; // Force the chatbot to open if embedded
}
// Removed css from here into the .css file - Refactored for Ver 1.7.3
// Initially hide the chatbot
if (chatbot_chatgpt_start_status === 'closed') {
chatGptChatBot.hide();
chatGptOpenButton.show();
} else {
if (chatbot_chatgpt_display_style === 'floating') {
if (chatbot_chatgpt_width_setting === 'Wide') {
$('#chatbot-chatgpt').removeClass('chatbot-narrow chatbot-full').addClass('chatbot-wide');
} else {
$('#chatbot-chatgpt').removeClass('chatbot-wide chatbot-full').addClass('chatbot-narrow');
}
// Overrides for mobile devices - Ver 1.8.1
if (isMobile()) {
// Initial update
updateChatbotStyles();
// Listen for orientation changes
window.addEventListener('orientationchange', updateChatbotStyles);
// Listen for resize events
window.addEventListener('resize', updateChatbotStyles);
}
chatGptChatBot.show();
chatGptOpenButton.hide();
} else {
$('#chatbot-chatgpt').removeClass('chatbot-wide chatbot-narrow').addClass('chatbot-full');
}
}
chatbotContainer = $('